package com.volunteer.controller;

import com.volunteer.common.R;
import com.volunteer.common.Result;
import com.volunteer.service.StatService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Tag(name = "统计数据接口")
@RestController
@RequestMapping("/stat")
@RequiredArgsConstructor
public class StatController {

    private final StatService statService;

    @Operation(summary = "获取平台统计数据")
    @GetMapping("/platform")
    public R<Map<String, Object>> getPlatformStats() {
        return R.ok(statService.getPlatformStats());
    }
    
    @Operation(summary = "获取管理员后台统计数据")
    @GetMapping("/admin/dashboard")
    public R<Map<String, Object>> getAdminDashboardStats() {
        return R.ok(statService.getAdminDashboardStats());
    }
    
    @Operation(summary = "获取活动趋势数据")
    @GetMapping("/activity/trend/{timeRange}")
    public R<Map<String, Object>> getActivityTrend(@PathVariable String timeRange) {
        return R.ok(statService.getActivityTrend(timeRange));
    }
    
    @Operation(summary = "获取用户增长趋势数据")
    @GetMapping("/user/growth/{timeRange}")
    public R<Map<String, Object>> getUserGrowthTrend(@PathVariable String timeRange) {
        return R.ok(statService.getUserGrowthTrend(timeRange));
    }
}
